/*
 * -------------------------------------- 
 * FileName: seq_list.h 
 * Content:
 *      顺序表
 * Auther:  杨则瑞 
 * Encode:  utf-8 | CRLF                  
 * -------------------------------------- 
 */

#ifndef _seq_list
#define _seq_list

#include<malloc.h>
#include<debuging.h>
#include<memory.h>



//命名空间宏
#define ns(title) sqList_##title

//顺序表错误
typedef enum ns(error_t)
{
    ns(OK),
    ns(INSUFFICIENT_MEMORORY),
    ns(INDEX_OUT_OF_BOUND),

} ns(error_t);

//顺序表
typedef struct 
{
    void * data;
    //单个元素大小
    size_t _elemSize;
    //元素长度
    size_t _len;
    //不重新分配内存，能容纳的元素数量
    size_t _capacity;
    //错误处理器
    ns(error_t) *_error_handler;

} ns(t);


void ns(init)  (ns(t) * self, size_t elemSize, ns(error_t) * error_handler);
void *ns(get) (ns(t) * self, size_t index);
void ns(reserve) (ns(t) * self, size_t new_len);
void *ns(insertive_get) (ns(t) * self, size_t index);
void ns(uninit) ( ns(t) * self);
void ns(erase) (ns(t) * self, size_t index);


#undef ns 
#endif